home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Day Cry
/
Day Cry CD.bin
/
oh_towns
/
ein
/
sources
/
cdpsrc.lzh
/
CDP
/
MAIN.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-09-05
|
12KB
|
408 lines
/*<Header>==============================================================
*
* ébécâvâîü[âä / "MAIN.C"
*
* [ EIN(tm) project : âTâôâvâïâvâìâOâëâÇ ]
*
* COPYRIGHT Nam 1994, All rights reserved.
*
* özòtüEægì₧üEëⁿò╧üEÅñùÿùpé╖é╫é─Ä⌐ùRüBé╜é╛é╡û│ò█Å╪é┴é╖
*
*-----------------------------------------------------------------------
* V1.0L01â┐ 94.04.07/Nam âvâìâgâ^âCâv
* V1.0L30 94.07.19/Nam EIN(TM)î÷èJö┼
* V1.0L31 94.09.05/Nam GM_QUITÄ₧é╔Ä⌐ò¬é┼WINDOWé≡Å┴ïÄ
*</Header>==============================================================*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <snd.h>
#include <winb.h>
#include <te.h>
#include <fntb.h>
#include <gui.h>
#include <egb.h>
//#include <file_dlg.h>
//#include <tifflib.h>
#include <msdos.cf>
#include <loader.h>
#include <math.h>
#include <io.h>
#include <guidbg.h>
//#include <wgb.h>
// üª é▒é▒é▄é┼é¬ò╜ï╧ôIé╔Ägùpé│éΩéΘâwâbâ_
#include "..\ein\eintm.h" // EIN(TM)è╓ÿAâëâCâuâëâèé╠âwâbâ_
#define ERROR (-1)
int ID_ICON[10];
int ID_PANEL[20];
int dispMode = 0; // 0:ICON / 1:PANEL
int showTime = 0; // 0:âgâëâbâNôαëëætÄ₧è╘, 1:âfâBâXâNôαëëætÄ₧è╘, 2:
/*= âèâWâàü[âÇùpÉ▌ÆΦ=================================================*/
int RSM_DISPMODE;
int RSM_SHOWTIME;
FRAME RSM_ICONFR;
FRAME RSM_PANELFR;
// âèâWâàü[âÇâ}âlü[âWââé╔Æ╩Æmé╖éΘüAâAâvâèÄ»ò╩IDüi63ò╢ÄÜê╚ë║é╠uniqé╚ò╢ÄÜù±üj
char RSMID[]="%%% CDPlayer icon %%%";
// âèâWâàü[âÇÅεò±é╔ûäé▀ì₧é▐â^âCâgâïò╢ÄÜù±üiâ^âXâNâèâXâgé╔éαò╣ùpüj
char RSMTITLE[]="ébécâvâîü[âä V0.1 L31";
// âèâWâàü[âÇÅεò±ô╟é▌Åæé½âoâbâtâ@é╠âTâCâYüiâAâvâèî┼ùLâTâCâYé╚é╠é┼Æ▓É«é╡é─é╦üj
#define RBUFSIZE (1024)
/*= âèâWâàü[âÇùpÉ▌ÆΦ=================================================*/
void ( *GV_defIdleTask )() ;
MMICTRL mmic = {
SCREEN16 | SCREENIGNORE, // resolution
SCREENUNUSED,
0, SCREENAVAILABLE, 0, // write_page,display_page,priority
SCREENAVAILABLE, // mode
SCREENEXPAND, // vram_x
0,0,0,0, // size,*ptr,asize,*atpr
0,0,0,0, // frame
-32767, // move
-32767,
32767,
32767,
15,8,7,15 // color
} ;
/*===================================================================*/
/* âüâCâôâïü[âv */
/*===================================================================*/
void main()
{
extern int APL_init() ;
int kobj;
// Åëè·ë╗Åêù¥
if (MMI_Open( &mmic ) == NOERR){
// ô±ÅdïNô«é╠check
if ( (kobj = MMI_CallMessage( MMI_GetApliId(), GM_QUERYID, QM_KIND, 1)) > NOERR ){
MMI_CallMessage( MMI_GetApliId(), GM_SWITCH, FALSE, kobj );
} else {
// âAâCâhâïâ^âXâNé╔ôoÿ^
setIdleTask() ;
// Åëè·ë╗é╔ɼî≈é╖éΩé╬âüâCâôâïü[âvé╔ôⁿéΘ.
if ( APL_init()==NOERR ){
MMI_ExecSystem();
}
// âAâCâhâïé╠ë≡Å£
resetIdleTask();
// âEâBâôâhâDÅ┴ïÄ(üªSHELLé╔Å┴ïÄé│é╣éΘé╞Æxéóé╠é┼)
eraseWin();
}
}
// ÅIù╣Åêù¥
MMI_Close() ;
}
/*===================================================================*/
/* Åëè·ë╗Åêù¥ */
/*===================================================================*/
int APL_init()
{
extern int clearCDstat();
extern int updateCDdisp(); // gui.c
extern int userFunc();
extern MMIINIT initDataRES_ICON ;
extern MMIINIT initDataRES_PANL ;
extern int ICONmaxId;
extern unsigned char *ICONTbl[];
char work[RSMWORKSIZE]; // âèâWâàü[âÇâ}âlü[âWââé╠âÅü[âNâGâèâA
char buf[RBUFSIZE];
char *ptr;
int size, x, y;
HYPER hyp;
register int ret ;
if ((ret = MMI_initHyper()) < 0) // ânâCâpü[î^
return ret;
if ((ret = MMI_initDialogL40()) < 0) // â_âCâAâìâOî^
return ret;
// if ((ret = MMI_initAlertL40()) < 0) // âAâëü[âgî^
// return ret;
if ((ret = MMI_initMessageL40()) < 0) // âüâbâZü[âWî^
return ret;
// if ((ret = MMI_initMenuL40()) < 0) // âüâjâàü[î^
// return ret;
if ((ret = MMI_initButtonL40()) < 0) // â{â^âôî^
return ret;
if ((ret = MMI_initDrawButtonL40()) < 0) // âhâìâEâ{â^âôî^
return ret;
// if ((ret = MMI_initToggleIconL40()) < 0) // âgâOâïâ{â^âôî^
// return ret;
if ((ret = MMI_initIconL40()) < 0) // âAâCâRâôî^
return ret;
// if ((ret = MMI_initScrollBarL40()) < 0) // âXâNâìü[âïâoü[î^
// return ret;
// if ((ret = MMI_initTextL40()) < 0) // âeâLâXâgî^
// return ret;
// if ((ret = MMI_initMenuItemL40()) < 0) // âüâjâàü[âAâCâeâÇî^
// return ret;
if ((ret = MMI_initWindowL40()) < 0) // âEâBâôâhâEî^
return ret;
// âfü[â^é╠ôoÿ^
if ((ret = MMI_Init(&initDataRES_ICON)) < 0)
return ret ;
if ((ret = MMI_Init(&initDataRES_PANL)) < 0)
return ret ;
/*----------------------------------*/
/* âAâCâRâôôoÿ^ */
/*----------------------------------*/
MMI_SetIconTable( ICONTbl, ICONmaxId ) ;
// 256,32ké╠Ä₧é╠GUIÉFé≡É▌ÆΦ
EIN_initGuiColor();
// âXâCâbâ`ââü[æ╬ë₧è╓Éöé╠ôoÿ^
MMI_SendMessage( MMI_GetBaseObj(), MM_SETEXEC, 1, userFunc ) ;
// â^âCâgâïé╠ôoÿ^
MMI_CallMessage( MMI_GetApliId(), GM_TITLE, (int)RSMTITLE, 0 ) ;
/*----------------------------------*/
/* âèâWâàü[âÇô╟é▌ì₧é▌ (üªé╠é┬éóé╜Åêù¥é═òKé╕ìsé┴é─é¡é╛é│éó) */
/*----------------------------------*/
// üªâèâWâàü[âÇâ}âlü[âWââé╠Åëè·ë╗(âAâvâèé╠IDâ^âOôoÿ^)
EIN_rsmInit( work, RSMID );
// üªô╟é▌ì₧é▌âoâbâtâ@É▌ÆΦ
EIN_rsmBufSet( work, buf, RBUFSIZE );
// üªâèâWâàü[âÇÅεò±ô╟é▌ì₧é▌
size = EIN_rsmLoad( work );
#ifdef DEBUG
printf(" resume size(%d)\n",size);
#endif
if ( size > 0 ){
// ò\Īâéü[âh( 0:ICON / 1:PANEL, ... )
if (((ptr = strstr(buf,"\nMODE: ")) != NULL ) &&
(sscanf(ptr,"\nMODE: %d %d\n", &x, &y) > 1 ) ){
dispMode = ( (x<0)||(x>1) ) ?0 :x;
showTime = ( (y<0)||(y>2) ) ?0 :y;
RSM_DISPMODE = dispMode;
RSM_SHOWTIME = showTime;
}
// ICONò\Īê╩Æu
if (((ptr = strstr(buf,"\nICON: ")) != NULL ) &&
(sscanf(ptr,"\nICON: %d %d\n", &x, &y) > 1 ) ){
MMI_SendMessage( ID_ICON[0], MM_GETHYPER, 1, &hyp ); // ÿgì└òWé≡ô╛éΘ
RSM_ICONFR.lupx = x;
RSM_ICONFR.lupy = y;
RSM_ICONFR.rdwx = x+(hyp.fr.rdwx-hyp.fr.lupx);
RSM_ICONFR.rdwy = y+(hyp.fr.rdwy-hyp.fr.lupy);
#ifdef DEBUG
printf("ICON: move to (%d,%d)\n", x, y);
#endif
if ( x<-31 ){
x=0;
}
if ( y<-31 ){
y=0;
}
MMI_SendMessage( ID_ICON[0], MM_MOVE, 1, &RSM_ICONFR ) ;
}
// PANELò\Īê╩Æu
if (((ptr = strstr(buf,"\nPANEL: ")) != NULL ) &&
(sscanf(ptr,"\nPANEL: %d %d\n", &x, &y) > 1 ) ){
MMI_SendMessage( ID_PANEL[0], MM_GETHYPER, 1, &hyp ); // ÿgì└òWé≡ô╛éΘ
RSM_PANELFR.lupx = x;
RSM_PANELFR.lupy = y;
RSM_PANELFR.rdwx = x+(hyp.fr.rdwx-hyp.fr.lupx);
RSM_PANELFR.rdwy = y+(hyp.fr.rdwy-hyp.fr.lupy);
#ifdef DEBUG
printf("PANEL: move to (%d,%d)\n", x, y);
#endif
if ( (x>=0)&&(x<1024)&&(y>=0)&&(y<712) ){
MMI_SendMessage( ID_PANEL[0], MM_MOVE, 1, &RSM_PANELFR ) ;
}
}
} else {
#ifdef DEBUG
printf("Can't find resume file.\n");
#endif
}
// âEâBâôâhâEù▐é≡ATTACHé╖éΘ
if ( dispMode == 0 ){
MMI_SendMessage( ID_ICON[0], MM_ATTACH, 1, MMI_GetBaseObj() ) ;
} else {
MMI_SendMessage( ID_PANEL[0], MM_ATTACH, 1, MMI_GetBaseObj() ) ;
}
// öwîié≡ò\Īé╖éΘ
MMI_SendMessage( MMI_GetBaseObj(), MM_SHOW, 0 ) ;
// CDÅεò±é≡ò\Ī
clearCDstat();
updateCDdisp( 1 );
return NOERR ;
}
/*===================================================================*/
/* âèâWâàü[âÇÅεò±ìXÉV (üªé¬é┬éóé╜Åêù¥é═òKé╕ìsé┴é─ë║é│éó) */
/*===================================================================*/
void SaveResumeFile()
{
char work[RSMWORKSIZE];
char buf[RBUFSIZE];
char aplpath[128];
HYPER hyp1,hyp2;
int ret;
// ÿgì└òWé≡ô╛éΘ
MMI_SendMessage( ID_ICON[0], MM_GETHYPER, 1, &hyp1 );
MMI_SendMessage( ID_PANEL[0],MM_GETHYPER, 1, &hyp2 );
// ò╧ë╗é╡é─éóé╜éτâZü[âu
if ( (RSM_DISPMODE != dispMode )||
// (RSM_SHOWTIME != showTime )||
(RSM_ICONFR.lupx != hyp1.fr.lupx)||
(RSM_ICONFR.lupy != hyp1.fr.lupy)||
(RSM_PANELFR.lupx != hyp2.fr.lupx)||
(RSM_PANELFR.lupy != hyp2.fr.lupy) ){
// üªâ}âlü[âWââÅëè·ë╗
EIN_rsmInit( work, RSMID );
// üªâoâbâtâ@É▌ÆΦ(âAâvâè